<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/socket.io.js" type="text/javascript" charset="utf-8"></script>
	</head>
	
	<body>
		<h1>小红</h1>
		<script type="text/javascript">
			//console.log(io)
			let con = io.connect("http://localhost:3000");
			con.on('connect',function(data){
				console.log("连接事件")
			})
			con.on('news',function(data){
				console.log(data)
				
			})
			
			con.on('hello',function(data){
				console.log(data)
			})
			
			
			//监听新用户加入事件
			con.on('addUser',function(data){
				console.log(data)
			})
			
			
			//监听某用户发送过来的信息
			con.on('sendClient',function(data){
				console.log(data)
			})
			
			//发送函数
			function send(){
				con.emit('my other event',{
					username:"小红",
					chatcontent:"吃饭了没？"
				})
			}
		</script>
	</body>
</html>
